<template>
  <div workbench-ask-list class="wrap-list">
    <div class="index-list-box" v-for="(items,i) in dataList" :key="i">
     <div style="margin-top:20px;position:relative;" class="box-inner">
        <div class="item">
        <div class="cell">
          <img :src="items.img_url1?items.img_url1:'/static/img/person2.jpg'" alt="">
          <div class="text">
            <h3>{{items.name}}</h3>
            <span>{{items.type}}</span>
          </div>
        </div>
        <i>{{items.showprice}}元</i>
      </div>
      <div class="center">
        <div>
          <!-- <p>{{items.name}}</p> -->
          <p>要求：{{items.describe}}</p>
          <p>任务周期：{{items.time}}</p>
        </div>
      </div>
            <div class="tmp">
               <button @click="finishHandle(items.id)" style="color: #ff5733 !important;">点击完成</button>

          </div>      <!-- <slot name="bottom"></slot> -->
     </div>
    </div>

  </div>
</template>
<style scoped lang="less" src="./style.less"></style>

<script>
  import './script.js'
export default {
  data() {
    return {
      dataList: []
    };
  },
  created() {
    this.init();
  },
  mounted() {},
  methods: {
    init() {
      this.axios
        .get("/api/job/doing", {
          params: { uid: JSON.parse(sessionStorage.getItem("user")).uid }
        })
        .then(res => {
          this.dataList = res.data.data;
          console.log(res.data.data);
          res.data.data.forEach(element => {
            console.log(element.id);
          });
        });
    },
    finishHandle(id){
      let params = {
        uid:JSON.parse(sessionStorage.getItem('user')).uid,
        taskid:id
      }
      this.axios.get('/api/task_finish_first',{params}).then(res=>{
        if(res.data.err_code ==0){
          this.$toast({message:res.data.data})
          this.init()
          this.$router.go(0)
        }else{
          this.$toast({message:res.data.err_msg})
          this.init()
        }
      }).catch(e=>{
        console.log(e)
      })
    }
  }
};
</script>
<style lang="less" scoped>
.wrap-list{
  background: #F8FAFE;
  margin-bottom: 60px;
}
.index-list-box{
  background: #fff;
  display: block;
  margin-bottom: 20px;
  margin-top: 20px;

}
.tmp{
  display: flex;
  justify-content: flex-end;
  padding-right: 20px;
  padding-bottom: 20px;
  font-size: 14px;
  color: #666;
}
</style>

